﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using Jarvis.Server.Domain;
using NUnit.Framework;

namespace Jarvis.Server.Test.ActionsTests
{
    [TestFixture]
    public class TerminateProgramActionTest
    {
        [Test]
        public void ShouldTerminateProcess()
        {

            Process.Start(
                @"E:\Documenti\Politecnico\jarvispso\Jarvis\Jarvis.Server\bin\Debug\Tools\Jarvis.Server.MessageDisplayer.exe","Message");


            Assert.That(Process.GetProcessesByName("Jarvis.Server.MessageDisplayer").Any());

            var reaction = new TerminateProgramAction()
                             {
                                 ProcessName = "Jarvis.Server.MessageDisplayer"
                             };

            Thread.Sleep(200);

            Assert.DoesNotThrow(reaction.Execute);

            Thread.Sleep(200);

            Assert.That(Process.GetProcessesByName("Jarvis.Server.MessageDisplayer").Any()==false);
        }
    }
}
